"""
    登录界面
"""
from common.commEle import CommEle
from common.getData import log_ele
from common.getData import user
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import time

class LoginPage(CommEle):
    def loginpage(self):
        """  输入用户名和密码 """
        self.find_element(By.CSS_SELECTOR, log_ele["登录元素"][0]).clear()
        self.find_element(By.CSS_SELECTOR,log_ele["登录元素"][0]).send_keys(user["用户名"][0])
        self.find_element(By.CSS_SELECTOR, log_ele["登录元素"][1]).clear()
        self.find_element(By.CSS_SELECTOR, log_ele["登录元素"][1]).send_keys(str(user["密码"][0]))
        """ 拖动滑动条 """
        ele = self.find_element(By.CSS_SELECTOR, log_ele["登录元素"][2])
        action = ActionChains(self.driver)
        action.click_and_hold(ele).perform()
        action.drag_and_drop_by_offset(ele, 400, 0).perform()
        time.sleep(1)
        """ 点击登录按钮 """
        self.find_element(By.CSS_SELECTOR, log_ele["登录元素"][3]).click()

if __name__ == "__main__":
    from selenium import webdriver
    url = log_ele["url"][0]
    driver = webdriver.Chrome()
    driver.get(url)
    login = LoginPage(driver)
    login.loginpage()





